from core.support import set_cutscene
from core.item import Item
from core.action import Action

class Bacardi151(Item):
    def __init__(self):
        Item.__init__(self, "bacardi151")    # do basic initialization for every item
        self.has_bacardi151 = True
        self.inuse = False
        self.incombouse = False
        # build list of actions
        self.add_action(usebacardi151)
    
    def get_description(self):
        if self.inuse:
            return "Bottle of Bacardi 151"
        else:
            return "Bottle of Bacardi 151"
        
        return "Bottle of Bacardi 151"

# define actions for this item

class usebacardi151(Action):
    def __init__(self):
        Action.__init__(self, "usebacardi151")    # do basic initialization for every action
    
    # return description of action (used in label on webpage)
    def get_description(self):
        return "Use Bacardi"
    
    # return http method to use when user clicks on this action
    # use "get" if just moving to another room.  if changing something
    # like the state of an inventory item or room then use "post"
    def get_method(self):
        return "post"
    
    def is_enabled(self):
        if self.item.incombouse:
            return False
        else:
            return True
    # only works in basement. add cutscene
    def do_action(self,game,room,request):
        if room.get_id() == 'sea8hearhello': 
            self.item.incombouse = True
            set_cutscene("Good as gas and twice the price, now what to light it with?")
            
        else:
            self.item.has_bacardi151 = False
            set_cutscene("This seems as good a time as any.  Puts hair on your chest and holes in your liver.")
            game.player.pop_item('bacardi151')
        return
